package com.lv.phuotbacnam.ui.activity;

import android.os.Bundle;

import com.lv.phuotbacnam.R;
import com.lv.phuotbacnam.ui.Constants;
import com.lv.phuotbacnam.ui.Section;
import com.lv.phuotbacnam.ui.fragment.ChiTietBaiDang;
import com.lv.phuotbacnam.ui.fragment.ChiTietDiaDiem;
import com.lv.phuotbacnam.ui.fragment.CreateNewBaiDang;
import com.lv.phuotbacnam.ui.fragment.CreateNewDiaDiem;
import com.lv.phuotbacnam.ui.fragment.GoogleMapChonViTriFragment;
import com.lv.phuotbacnam.ui.fragment.SuaBaiDang;
import com.lv.phuotbacnam.ui.fragment.SuaDiaDiem;

public class BackActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_back);
		init();

		try {
			Bundle bundle = getIntent().getExtras();
			Section fragment = (Section) bundle
					.getSerializable(Constants.KEY_INTENT_FOR_FRAGMENT);
			goToFragment(fragment);
		} catch (Exception e) {
			this.finish();
		}
	}

	private void init() {
		initializeNavigationBarBack();
	}

	private void goToFragment(Section fragment) {
		switch (fragment) {
		case CREATE_NEW_BAI_DANG:
			navigateTo(CreateNewBaiDang.class, Section.NONE, null, false);
			break;

		case CREATE_NEW_DIA_DIEM:
			navigateTo(CreateNewDiaDiem.class, Section.NONE, null, false);
			break;
		case GOOGLE_MAP_CHON_VI_TRI:
			navigateTo(GoogleMapChonViTriFragment.class, Section.NONE, null,
					false);
			break;
		case CHI_TIET_BAI_DANG:
			navigateTo(ChiTietBaiDang.class, Section.NONE, null, false);
			break;
		case CHINH_SUA_BAI_DANG:
			navigateTo(SuaBaiDang.class, Section.NONE, null, false);
			break;
		case CHINH_SUA_DIA_DIEM:
			navigateTo(SuaDiaDiem.class, Section.NONE, null, false);
			break;
		case CHI_TIET_DIA_DIEM:
			navigateTo(ChiTietDiaDiem.class, Section.NONE, null, false);
			break;
		case NONE:
			break;
		default:
			break;
		}
	}

	@Override
	protected int getContainerId() {
		// TODO Auto-generated method stub
		return R.id.container;
	}

}
